[
define_atbegin: {



	var('the_file_exists'=true);
	if(string(response_filepath) ==  '/');
		
		log_critical('at_begin is redirecting to /Home/ from line 8');
		redirect_url('/Home/');
	else(
		string(response_filepath)->endswith('.lassoapp')
		|| (string(response_filepath)->endswith('.xml'))
		|| (string(response_filepath)->endswith('.html'))
		|| (string(response_filepath)->endswith('.las'))
		);
			// don't do nuffin
	else(string(response_filepath) -> endswith('.lasso'));
			//see if file exists
			protect;
					null(include_raw(response_filepath));
					handle_error;
							$the_file_exists = false;
					/handle_error;
			/protect;
		
			if($the_file_exists);
					//do nothing
			else;
			
					$__HTML_REPLY__ = include: '/_Makerator/hub.lasso';
					abort;
					
			/if;
	else;
		// run site
			string(response_filepath)->endswith('.inc') ? abort;
			
			local(
				'go' = true,
				'rf' = @response_filepath
			);
			
			(
				#rf->endswith('.lasso')
				|| #rf->endswith('.lassoapp')
				|| #rf->endswith('.html')
				|| #rf->beginswith('/_Makerator')
				|| #rf->beginswith('/Assets')
				|| #rf->beginswith('/_Site')
				|| (!#rf->endswith('/'))
			) ? #go = false;

			if(#go);
					$__HTML_REPLY__ = @include('/_Makerator/hub.lasso');
					abort;
					
					
			// workaround for behavior change in Apache 2.x.
			// updated for Apache 2.2.6 on Mac and Win
			else(#rf->endswith('/'));
					local('exts') = (: 'html', 'lasso');
					local('path') = string(#rf) + 'index.';
					
					iterate(#exts, local('i'));
						local('p') = #path + #i;
						local('continue') = true;
						
						protect;
							null(include_raw(#p));
							
							handle_error;
								#continue = false;
							/handle_error;
						/protect;
						
						!#continue ? loop_continue;
						redirect_url(#p);
					/iterate;
			else;
					local('path') = string(#rf) + '/';
					log_critical('at_begin is redirecting to: ' #path);
					redirect_url(#path);
			/if;
			
			
			
			$__HTML_REPLY__ = response_filepath;

	/if;
}
]